package com.tstudy.laoshibang.mode;

import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import android.text.TextUtils;

/**
 * 吐槽消息列表model类
* @CopyRight tstudy.com.cn
* @author wuyahui
* @E-mail wuyahui0124505@163.com
* @version 1.0.0
* @Date 2015年6月3日 上午11:27:02
 */
@DatabaseTable
public class CommunityMessage implements BaseModel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6079788363862247150L;
	
	public User user;//	用户对象	Json
	public List<Idxe> idxes;//吐槽图片
	@DatabaseField(id = true)
	public int tcComId;
	@DatabaseField
	public String userStr;
	@DatabaseField
	public String idxeStr;
	@DatabaseField
	public int tcId;//	吐槽表主键	Int
	@DatabaseField
	public String createTime;
	@DatabaseField
	public int hasRead;//是否已读
	@DatabaseField
	public String tcContent;//吐槽内容
	@DatabaseField
	public String comContent;//评论内容
	@DatabaseField
	public int tcUreadNum;//未读数量
	@DatabaseField
	public String groupId;//组Id；
	
	@DatabaseField
	public String tcTitle;//吐槽标题
	@DatabaseField
	public String tcTypeStr;
	
	public DicMap tcType;//吐槽类型
	
//	public DicMap tcIsAnous;//
	
	public void parseObject(){
		if (!TextUtils.isEmpty(userStr)) {
			user = new Gson().fromJson(userStr,User.class);
		}
		if (!TextUtils.isEmpty(tcTypeStr)) {
			tcType = new Gson().fromJson(tcTypeStr,DicMap.class);
		}
		if (!TextUtils.isEmpty(idxeStr)) {
			idxes = new Gson().fromJson(idxeStr,new TypeToken<List<Idxe>>(){}.getType());
		}
	}
	
	public void objectToString(){
		if (user != null) {
			userStr = new Gson().toJson(user);
		}
		if (tcType != null) {
			tcTypeStr = new Gson().toJson(tcType);
		}
		if (idxes != null) {
			idxeStr = new Gson().toJson(idxes);
		}
	}
	
	
}
